using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace CubicFWNet.Data.Models.Mapping
{
    public class UserMap : EntityTypeConfiguration<User>
    {
        public UserMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.UserName)
                .IsRequired()
                .HasMaxLength(64);

            this.Property(t => t.RealName)
                .HasMaxLength(64);

            this.Property(t => t.ShortName)
                .IsFixedLength()
                .HasMaxLength(64);

            this.Property(t => t.Password)
                .IsRequired()
                .HasMaxLength(128);

            this.Property(t => t.MobilePhone)
                .IsFixedLength()
                .HasMaxLength(64);

            this.Property(t => t.Email)
                .HasMaxLength(128);


            this.Property(t => t.Memo)
                .HasMaxLength(1024);

            // Table & Column Mappings
            this.ToTable("User");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.UserName).HasColumnName("UserName");
            this.Property(t => t.RealName).HasColumnName("RealName");
            this.Property(t => t.ShortName).HasColumnName("ShortName");
            this.Property(t => t.Password).HasColumnName("Password");
            this.Property(t => t.MobilePhone).HasColumnName("MobilePhone");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Birthday).HasColumnName("Birthday");
            this.Property(t => t.JoinTime).HasColumnName("JoinTime");
            this.Property(t => t.CreateTime).HasColumnName("CreateTime");
            this.Property(t => t.CreatorId).HasColumnName("CreatorId");
            this.Property(t => t.SortNo).HasColumnName("SortNo");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.Memo).HasColumnName("Memo");
        }
    }
}
